package com.wang.tool.hook;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;

class Demo {


    public static void main(String[] args) {
//        应用钩子，完成应用初始化加载，结束回收的钩子
//        统一线程池管理，环境管理，springUtil管理等...

//        启动类添加注解@EnableAppHook
//        配置AppHook实现类即可
//        示例：SpringContextUtil
//        EnvUtil

    }


    /**
     * 提供静态函数获取环境
     */
    private static class EnvUtil implements AppHook{
        private static String env = null;

        @Override
        public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
            Environment environment = applicationContext.getEnvironment();
            env = environment.getProperty("spring.env");
        }


        public static String getEnv() {
            return env;
        }
    }
}